/*******************************************************************************
 * Copyright (c) 2010 liw.
 * All rights reserved. 
 * 
 * This file is part of VanBus.
 * 
 *     VanBus is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     VanBus is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with VanBus.  If not, see <http://www.gnu.org/licenses/>.
 * Contributors:
 *     liw - initial API and implementation
 ******************************************************************************/
package org.niclab.vanbus.query;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.EnumMap;
import java.util.Map;

import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestBase;
import org.niclab.vanbus.application.VanBusApplication;
import org.niclab.vanbus.query.BusDirQuery.InputParams;

import android.content.Context;
import android.util.Log;

//I: input
//R: result
public abstract class AbstractQuery<I extends Enum<I>> implements IQuery<I>{

	private final String LOG_TAG="AbastrctQuery";


	private Object queryResult;
	private boolean queryFinished = false;
	private Map<I,Object> inputParams;

	
	public AbstractQuery(Class<I> c){

		inputParams = new EnumMap<I,Object>(c);
		
	}
	protected Context getApplicationContext(){
		return VanBusApplication.getInstance();
	}
	@Override
	public boolean isQueryFinished(){
		return queryFinished;
	}
	
	@Override
	public void setQueryFinished(boolean finished){
		this.queryFinished = finished;
	}
	
	@Override
	public String getDBQuery(){
		return null;
	}
	@Override
	public String getMemQuery(){
		return null;
	}
/*	@Override
	public Context getInitiatorContext(){
		return this.context;
	}*/

	@Override
	public void addQueryInputParam(I e, Object obj){
		Log.v(LOG_TAG, "addQueryInputParam: "+ inputParams.size());
		inputParams.put(e, obj);
	}
	@Override
	public Object getQueryInputParam(I e){
		return inputParams.get(e);
	}

	public Map<I,Object> getQueryInput(){
		return inputParams;
	}

	@Override
	public Object getQueryResult(){
		return queryResult;
		
	}
	
	@Override
	public void setQueryResult(Object result){
		
		this.queryResult = result;
	}
	
	

	
}
